#!/usr/bin/env perl
use 5.010;
use strict;

# greet子程序
# 参数：人名 
# 结果：打印欢迎信息,并告诉前一个来宾的名字
sub greet {
    state $last_one;
    my $user = shift @_;
    if ( !defined $last_one ) {
        print "Hi $user! You are the first one here!\n";
    } else {
        print "Hi $user! $last_one is also here!\n";
    }
    $last_one = $user;
}

#测试greet子程序
greet("Fred");

greet("Barney");
